[scheduler] Add sqlx warnings as sentry events#2250
[scheduler] Add sqlx warnings as sentry events#2250DiegoTavares merged 1 commit intoAcademySoftwareFoundation:masterfrom
Conversation
📝 WalkthroughWalkthroughThe Sentry tracing integration in the scheduler's main entry point is updated from an unfiltered default layer to a customized layer with an event_filter. This filter categorizes logs as Sentry events or breadcrumbs based on their target and severity level. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
rust/crates/scheduler/src/main.rs (1)
296-305: Logic is correct and achieves the PR objective.The event filter correctly routes:
- sqlx WARN → Sentry Event
- Any ERROR → Sentry Event
- Everything else → Breadcrumb
This integrates well with the EnvFilter config (
info,sqlx=warn) which ensures sqlx WARN messages reach this layer.Minor style nit: There's an inconsistency in level comparisons—line 298 uses
*metadata.level()(dereferenced) while line 299 usesmetadata.level()(reference). Both work, but unifying them would improve readability.,
Optional: unify comparison style
let sentry_layer = sentry::integrations::tracing::layer().event_filter(|metadata| { // Register sqlx WARN messages as Sentry issues (events) instead of breadcrumbs - if (metadata.target().starts_with("sqlx") && *metadata.level() == tracing::Level::WARN) - || metadata.level() <= &tracing::Level::ERROR + if (metadata.target().starts_with("sqlx") && *metadata.level() == tracing::Level::WARN) + || *metadata.level() <= tracing::Level::ERROR { sentry::integrations::tracing::EventFilter::Event } else { sentry::integrations::tracing::EventFilter::Breadcrumb } });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rust/crates/scheduler/src/main.rs` around lines 296 - 305, The sentry_layer event_filter mixes dereferenced and referenced level comparisons; make them consistent by using the same form for both comparisons (e.g., dereference metadata.level() in both places or compare references in both places). Update the closure in sentry::integrations::tracing::layer().event_filter so the checks use the same style (referencing the symbol sentry_layer and the closure's metadata.level(), and comparing against tracing::Level::WARN and tracing::Level::ERROR consistently) to improve readability.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@rust/crates/scheduler/src/main.rs`:
- Around line 296-305: The sentry_layer event_filter mixes dereferenced and
referenced level comparisons; make them consistent by using the same form for
both comparisons (e.g., dereference metadata.level() in both places or compare
references in both places). Update the closure in
sentry::integrations::tracing::layer().event_filter so the checks use the same
style (referencing the symbol sentry_layer and the closure's metadata.level(),
and comparing against tracing::Level::WARN and tracing::Level::ERROR
consistently) to improve readability.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 58e626c3-5c27-4842-bd2e-6f141c529b6e
📒 Files selected for processing (1)
rust/crates/scheduler/src/main.rs
cc5c264
into
AcademySoftwareFoundation:master
Related Issues
sqlx warnings should be tracked by sentry
Summarize your change.
Treat sentry sqlx warnings as events
Summary by CodeRabbit